package com.xnfh.home.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.xnfh.framework.bean.ProductIntroduceItem
import com.xnfh.home.R
import com.xnfh.home.databinding.ItemProductIntroduceBinding
import com.xnfh.image.ImageHelper
import com.xnfh.image.ImageUrl

/**
 * @Description: 产品介绍 item
 * @Author: ziheng
 * @CreateDate: 2023/10/12 1:40 PM
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/10/12 1:40 PM
 * @UpdateRemark: 更新说明
 */
class ProductIntroduceAdapter :
    BaseQuickAdapter<ProductIntroduceItem, BaseDataBindingHolder<ItemProductIntroduceBinding>>(R.layout.item_product_introduce) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemProductIntroduceBinding>,
        item: ProductIntroduceItem
    ) {
        val dataBinding = holder.dataBinding
        if (item.tableImgList.isNotEmpty()) {
            ImageHelper.instance.loadNetImg(
                context,
                ImageUrl.BASEURL + item.tableImgList[0].pathUrl,
                dataBinding?.itemProductIntroduceImg,
                com.xnfh.common.R.mipmap.image_error,
                com.xnfh.common.R.mipmap.image_error
            )
        }
        holder.setText(R.id.item_product_introduce_type, item.productTypeName)
        holder.setText(R.id.item_product_introduce_title, item.productName)
        holder.setText(R.id.item_product_introduce_peibi,"(${item.productMatch})")
        holder.setText(
            R.id.item_product_introduce_connect,
            "${context.getString(R.string.str_product_syzw_mao)}${item.productCrop}"
        )
    }
}